package com.wzg.myobjectbox.greenDao.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.wzg.myobjectbox.greenDao.Converter.ItemDtoConverter;
import com.wzg.myobjectbox.greenDao.Converter.SingleItemDtoConverter;
import com.wzg.myobjectbox.greenDao.Converter.StringConverter;
import com.wzg.myobjectbox.greenDao.bean.ItemListDTO;
import java.util.List;

import com.wzg.myobjectbox.greenDao.bean.InspectionReportRs;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "INSPECTION_REPORT_RS".
*/
public class InspectionReportRsDao extends AbstractDao<InspectionReportRs, Long> {

    public static final String TABLENAME = "INSPECTION_REPORT_RS";

    /**
     * Properties of entity InspectionReportRs.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property InsId = new Property(0, long.class, "insId", true, "_id");
        public final static Property Id = new Property(1, Integer.class, "id", false, "ID");
        public final static Property SchemeCode = new Property(2, String.class, "schemeCode", false, "SCHEME_CODE");
        public final static Property ManagerName = new Property(3, String.class, "managerName", false, "MANAGER_NAME");
        public final static Property CreateTime = new Property(4, String.class, "createTime", false, "CREATE_TIME");
        public final static Property ItemList = new Property(5, String.class, "itemList", false, "ITEM_LIST");
        public final static Property Item = new Property(6, String.class, "item", false, "ITEM");
        public final static Property Imgs = new Property(7, String.class, "imgs", false, "IMGS");
    }

    private final ItemDtoConverter itemListConverter = new ItemDtoConverter();
    private final SingleItemDtoConverter itemConverter = new SingleItemDtoConverter();
    private final StringConverter imgsConverter = new StringConverter();

    public InspectionReportRsDao(DaoConfig config) {
        super(config);
    }
    
    public InspectionReportRsDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"INSPECTION_REPORT_RS\" (" + //
                "\"_id\" INTEGER PRIMARY KEY NOT NULL ," + // 0: insId
                "\"ID\" INTEGER," + // 1: id
                "\"SCHEME_CODE\" TEXT," + // 2: schemeCode
                "\"MANAGER_NAME\" TEXT UNIQUE ," + // 3: managerName
                "\"CREATE_TIME\" TEXT," + // 4: createTime
                "\"ITEM_LIST\" TEXT," + // 5: itemList
                "\"ITEM\" TEXT," + // 6: item
                "\"IMGS\" TEXT);"); // 7: imgs
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"INSPECTION_REPORT_RS\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, InspectionReportRs entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getInsId());
 
        Integer id = entity.getId();
        if (id != null) {
            stmt.bindLong(2, id);
        }
 
        String schemeCode = entity.getSchemeCode();
        if (schemeCode != null) {
            stmt.bindString(3, schemeCode);
        }
 
        String managerName = entity.getManagerName();
        if (managerName != null) {
            stmt.bindString(4, managerName);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
 
        List itemList = entity.getItemList();
        if (itemList != null) {
            stmt.bindString(6, itemListConverter.convertToDatabaseValue(itemList));
        }
 
        ItemListDTO item = entity.getItem();
        if (item != null) {
            stmt.bindString(7, itemConverter.convertToDatabaseValue(item));
        }
 
        List imgs = entity.getImgs();
        if (imgs != null) {
            stmt.bindString(8, imgsConverter.convertToDatabaseValue(imgs));
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, InspectionReportRs entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getInsId());
 
        Integer id = entity.getId();
        if (id != null) {
            stmt.bindLong(2, id);
        }
 
        String schemeCode = entity.getSchemeCode();
        if (schemeCode != null) {
            stmt.bindString(3, schemeCode);
        }
 
        String managerName = entity.getManagerName();
        if (managerName != null) {
            stmt.bindString(4, managerName);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
 
        List itemList = entity.getItemList();
        if (itemList != null) {
            stmt.bindString(6, itemListConverter.convertToDatabaseValue(itemList));
        }
 
        ItemListDTO item = entity.getItem();
        if (item != null) {
            stmt.bindString(7, itemConverter.convertToDatabaseValue(item));
        }
 
        List imgs = entity.getImgs();
        if (imgs != null) {
            stmt.bindString(8, imgsConverter.convertToDatabaseValue(imgs));
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.getLong(offset + 0);
    }    

    @Override
    public InspectionReportRs readEntity(Cursor cursor, int offset) {
        InspectionReportRs entity = new InspectionReportRs( //
            cursor.getLong(offset + 0), // insId
            cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1), // id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // schemeCode
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // managerName
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // createTime
            cursor.isNull(offset + 5) ? null : itemListConverter.convertToEntityProperty(cursor.getString(offset + 5)), // itemList
            cursor.isNull(offset + 6) ? null : itemConverter.convertToEntityProperty(cursor.getString(offset + 6)), // item
            cursor.isNull(offset + 7) ? null : imgsConverter.convertToEntityProperty(cursor.getString(offset + 7)) // imgs
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, InspectionReportRs entity, int offset) {
        entity.setInsId(cursor.getLong(offset + 0));
        entity.setId(cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1));
        entity.setSchemeCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setManagerName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCreateTime(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setItemList(cursor.isNull(offset + 5) ? null : itemListConverter.convertToEntityProperty(cursor.getString(offset + 5)));
        entity.setItem(cursor.isNull(offset + 6) ? null : itemConverter.convertToEntityProperty(cursor.getString(offset + 6)));
        entity.setImgs(cursor.isNull(offset + 7) ? null : imgsConverter.convertToEntityProperty(cursor.getString(offset + 7)));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(InspectionReportRs entity, long rowId) {
        entity.setInsId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(InspectionReportRs entity) {
        if(entity != null) {
            return entity.getInsId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(InspectionReportRs entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
